import java.util.ArrayList;
import java.util.List;

/**
 * @Author liangzai
 * @Description:
 */
public class Training {
    //字符串的分数
    public int scoreOfString(String s) {
        char[] c = s.toCharArray();
        int res = 0;
        for (int i = 1; i < s.length(); i++) {
            res += Math.abs(c[i] - c[i - 1]);
        }
        return res;
    }

    //石头游戏2
    public int stoneGameVI(int[] a, int[] b) {
        int n = a.length;
        List<int[]> list = new ArrayList<>();
        for (int i = 0; i < n; ++i)
            list.add(new int[]{a[i] + b[i], a[i], b[i]});
        list.sort((x, y) -> y[0] - x[0]);
        int res = 0;
        for (int i = 0; i < n; ++i)
            res += i % 2 == 0 ? list.get(i)[1] : -list.get(i)[2];
        return Integer.compare(res, 0);
    }

}
